package mycine.model.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Vincent
 */
public abstract class DAO {
	
	private static EntityManagerFactory emf = Persistence.createEntityManagerFactory("MyCinePU");
	protected static EntityManager em = null;

	protected EntityManager getEntityManager() {
		if (em == null || !em.isOpen()) {
			em = emf.createEntityManager();
		}

		return em;
	}
	
}
